package com.cheng.operation.impl;

import com.cheng.common.exception.CommonException;
import com.cheng.data.entity.EntpTypeInfEntity;
import com.cheng.operation.EntpTypeInfOperation;
import com.cheng.service.EntpTypeInfService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: ChengJW
 * @date: 2021/11/8 8:37
 * @version: 1.0
 * @description: 关于企业类型信息表 entp_type_inf 表的业务逻辑操作
 */
@Service
public class EntpTypeInfOperationImpl implements EntpTypeInfOperation {

    private final static Logger log = LoggerFactory.getLogger(EntpTypeInfOperationImpl.class);

    @Autowired
    private EntpTypeInfService entpTypeInfService;


    /**
     * @author: ChengJW
     * @params: [entity]
     * @return: java.util.List<com.cheng.data.entity.EntpTypeInfEntity>
     * @date: 2021/11/8
     * @description: 查询 entp_type_inf 表信息
     */
    @Override
    public List<EntpTypeInfEntity> queryEntpTypeInf(EntpTypeInfEntity entity) throws CommonException {
        return entpTypeInfService.queryEntpTypeInf(entity);
    }

    /**
     * @author: ChengJW
     * @params: [entity]
     * @return: com.cheng.data.entity.EntpTypeInfEntity
     * @date: 2021/11/8
     * @description: 根据 code 查询单条 entp_type_inf 记录的中文描述
     */
    @Override
    public String queryEntpTypeInfByCode(String code) throws CommonException{
        EntpTypeInfEntity entity = new EntpTypeInfEntity();
        entity.setEpTypeCode(code);
        List<EntpTypeInfEntity> list = queryEntpTypeInf(entity);
        EntpTypeInfEntity entpTypeInfEntity = new EntpTypeInfEntity();
        if (null != list && list.size() > 0){
            entpTypeInfEntity = list.get(0);
        }
        return entpTypeInfEntity.getEpTypeNm();
    }
}
